package com.eeepay.v2_library.api;



import com.eeepay.v2_library.log.LogUtils;

import java.io.UnsupportedEncodingException;



/***
 * 网络请求工具类
 *
 */
public class HttpTaskUtil {

	private static HttpTaskUtil instance;
	private int currentVersion = android.os.Build.VERSION.SDK_INT;

	public static HttpTaskUtil getInstance() {
		if (instance == null) {
			instance = new HttpTaskUtil();
		}
		return instance;
	}

	public void doHttpTask(Task task, RequestCallBack responselistener) {
		if(LogUtils.allowD){
			try {
				LogUtils.d("tag="+task.getmTaskId()+" url=>"+task.getUrl()+WebUtils.buildQuery(task.getParams(), "test"));
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		
		
		if (currentVersion >= 11) {
			new HttpRequestAsyncTask(task, responselistener).execute();
		} else {
			new RequestAsyncTask(task,responselistener).execute();
		}
	}
}
